$(document).ready(function() {
  var $table = $('#worker-table');
  $table.bootstrapTable({
    data: data,
    pagination: true,
    pageSize: 10
  });

  initOrg();
});

var data = [
  {
    field0: 1,
    field1: '王涛',
    field2: '质量部部长',
    field3: '质量部',
    field4: '18245246851',
  },
  {
    field0: 2,
    field1: '程菲',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 3,
    field1: '陶波',
    field2: '技术负责人',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 4,
    field1: '李依依',
    field2: '试验员',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 5,
    field1: '董小姐',
    field2: '资料管理员',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 6,
    field1: '陈飞',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 7,
    field1: '孙韬',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 8,
    field1: '秦钱',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 9,
    field1: '周晓明',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 10,
    field1: '陈红',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 11,
    field1: '毛阿敏',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 12,
    field1: '徐阳',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  },
  {
    field0: 13,
    field1: '陈红',
    field2: '试验工程师',
    field3: '科信试验室',
    field4: '18245246851',
  }
];

function initOrg() {
  // 模拟平安后台的用户管理的查询条件--单位
  // $('#_s_org_id').combotree({
  //   url: getRootPath() + "/sys/api/org/query",
  //   method: 'POST',
  //   animate: true,
  //   queryParams: {},
  //   loadFilter: function (data) {
  //       return convert(data.rows);
  //   },
  //   onLoadSuccess:function(node,data){
  //       if(data.length>0){
  //           $('#orgId').combotree("setValue",data[0].id);
  //       }
  //   }
  // });
}

// 查询部门/项目

function addDepart(){
  $('#department-project').modal('show');
}

function getCheckBox(id, row) {
  var html = '<input type="checkbox" name="checkbox" sid="' + id + '">';
  return html;
}

//用户，全选/全不选
function selectAll(ele) {
  var bool = $(ele).is(':checked');
  $('input[name="checkbox"]').prop("checked", bool);
};

function clickOperate(id, row) {
  var roleIds = row.roleIds;
  // 传值给click事件
  return "<a class='qn-check J_menuItem' href='workerInfoDetail.html'>查看</a>" +
         "<a class='qn-check' onclick='deployDialog(`" + id + "`)'>调配</a>";
}

// 删除
function deleteWorker() {
  var ids = $.map($('input[name="checkbox"]'), function (item) {
    if ($(item).is(':checked')) {
      return $(item).attr("sid");
    }
  });
  if(ids.length == 0){
    showAlert(null,"请选择数据后再删除");
    return;
  }
  showConfirm("提示","是否确定删除？",function() {
    
  });
}

// 调配
function deployDialog() {
  $('#deploy-form').modal('show');
}